---
description: Checks if a label component is associated with a form element
optionExamples:
  - 'true'
  - '[true, {"controlComponents": ["app-input"]}]'
  - |-
    [
      true,
      {
        "controlComponents": ["app-input", "app-select"],
        "labelAttributes": ["id"],
        "labelComponents": ["app-label"]
      }
    ]
options:
  additionalProperties: false
  properties:
    controlComponents: &ref_0
      properties:
        items:
          type: string
        type: array
        uniqueItems: true
      type: object
    labelAttributes: *ref_0
    labelComponents: *ref_0
  type: object
optionsDescription: |-

  An optional object with optional `controlComponents`, `labelAttributes` and `labelComponents` properties.

  * `controlComponents` - components that must be inside a label component. Default and non overridable values are
  "button", "input", "meter", "output", "progress", "select" and "textarea".
  * `labelAttributes` - attributes that must be set on label components. Default and non overridable values are
  "for" and "htmlFor".
  * `labelComponents` - components that act like a label. Default and non overridable values are
  "label".
      
ruleName: template-accessibility-label-for
type: functionality
typescriptOnly: true
layout: rule
title: 'Rule: template-accessibility-label-for'
optionsJSON: |-
  {
    "additionalProperties": false,
    "properties": {
      "controlComponents": {
        "properties": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "uniqueItems": true
        },
        "type": "object"
      },
      "labelAttributes": {
        "properties": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "uniqueItems": true
        },
        "type": "object"
      },
      "labelComponents": {
        "properties": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "uniqueItems": true
        },
        "type": "object"
      }
    },
    "type": "object"
  }
---